<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    
    <title>NodeJS文件系统（fs）与流（stream） | Anson&#39;s Blog | 种一棵树最好的时间在十年前，其次是现在。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="NodeJS">
    <meta name="description" content="文件系统（File System）： 在Node中，文件系统的交互是非常重要的，服务器的本质就是将本地的文件发送给客户端， Node通过fs模块来和文件系统进行交互，该模块提供了一些标准的文件访问API类打开、读取、写入文件、以及与其交互。 要是用fs模块，首先要从核心模块中加载； 使用 const fs= require(‘fs’) ; 来引入  fs使用特点： fs模块中的所有操作都有两种形式">
<meta name="keywords" content="NodeJS">
<meta property="og:type" content="article">
<meta property="og:title" content="NodeJS文件系统（fs）与流（stream）">
<meta property="og:url" content="http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/index.html">
<meta property="og:site_name" content="Anson&#39;s Blog">
<meta property="og:description" content="文件系统（File System）： 在Node中，文件系统的交互是非常重要的，服务器的本质就是将本地的文件发送给客户端， Node通过fs模块来和文件系统进行交互，该模块提供了一些标准的文件访问API类打开、读取、写入文件、以及与其交互。 要是用fs模块，首先要从核心模块中加载； 使用 const fs= require(‘fs’) ; 来引入  fs使用特点： fs模块中的所有操作都有两种形式">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2018-12-21T08:22:45.054Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="NodeJS文件系统（fs）与流（stream）">
<meta name="twitter:description" content="文件系统（File System）： 在Node中，文件系统的交互是非常重要的，服务器的本质就是将本地的文件发送给客户端， Node通过fs模块来和文件系统进行交互，该模块提供了一些标准的文件访问API类打开、读取、写入文件、以及与其交互。 要是用fs模块，首先要从核心模块中加载； 使用 const fs= require(‘fs’) ; 来引入  fs使用特点： fs模块中的所有操作都有两种形式">
    
        <link rel="alternate" type="application/atom+xml" title="Anson&#39;s Blog" href="/atom.xml">
    
    <link rel="shortcut icon" href="/img/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>

    <!-- custom head -->
    

</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu"  >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="https://yscoder.github.io/img/face.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">张宁乐</h5>
          <a href="mailto:zhangningle2017@gmail.com" title="zhangningle2017@gmail.com" class="mail">zhangningle2017@gmail.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/archives"  >
                <i class="icon icon-lg icon-archives"></i>
                归档
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/about"  >
                <i class="icon icon-lg icon-user"></i>
                关于
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/ansonznl" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">NodeJS文件系统（fs）与流（stream）</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">NodeJS文件系统（fs）与流（stream）</h1>
        <h5 class="subtitle">
            
                <time datetime="2018-11-08T06:04:55.000Z" itemprop="datePublished" class="page-time">
  2018-11-08
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap post-toc-shrink" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#文件系统（File-System）："><span class="post-toc-number">1.</span> <span class="post-toc-text">文件系统（File System）：</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#fs使用特点："><span class="post-toc-number">1.1.</span> <span class="post-toc-text">fs使用特点：</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#文件操作："><span class="post-toc-number">1.2.</span> <span class="post-toc-text">文件操作：</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#使用文件流写入"><span class="post-toc-number">1.3.</span> <span class="post-toc-text">使用文件流写入</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#读写文件："><span class="post-toc-number">1.4.</span> <span class="post-toc-text">读写文件：</span></a></li></ol></li></ol>
        </nav>
    </aside>


<article id="post-NodeJs文件系统（fs）与流（stream）"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">NodeJS文件系统（fs）与流（stream）</h1>
        <div class="post-meta">
            <time class="post-time" title="2018-11-08 14:04:55" datetime="2018-11-08T06:04:55.000Z"  itemprop="datePublished">
2018-11-08
<!--2018-12-21 16:22:45-->
</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="文件系统（File-System）："><a href="#文件系统（File-System）：" class="headerlink" title="文件系统（File System）："></a><strong>文件系统（File System）：</strong></h2><ol>
<li>在Node中，文件系统的交互是非常重要的，服务器的本质就是将本地的文件发送给客户端，</li>
<li>Node通过fs模块来和文件系统进行交互，该模块提供了一些标准的文件访问API类打开、读取、写入文件、以及与其交互。</li>
<li>要是用fs模块，首先要从核心模块中加载； 使用 const fs= require(‘fs’) ; 来引入</li>
</ol>
<h3 id="fs使用特点："><a href="#fs使用特点：" class="headerlink" title="fs使用特点："></a>fs使用特点：</h3><ol>
<li>fs模块中的所有操作都有两种形式可供选择同步和异步，</li>
<li>同步文件系统会阻塞程序的执行，也就是除非操作完毕，否则不会向下执行代码。</li>
<li>异步文件系统不会阻塞程序的执行，而是在操作完成时，通过回调函数将结果返回。</li>
</ol>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line">//1\. 引入模块</span><br><span class="line">const fs= require(&quot;fs&quot;);</span><br><span class="line">// console.log(fs)</span><br><span class="line"></span><br><span class="line">//2\. 打开文件</span><br><span class="line">// fs.open 异步读取（通常用异步 需设置回调函数）  </span><br><span class="line">// fs.openSync 同步读取（读取时会阻塞线程）</span><br><span class="line"></span><br><span class="line">let hello = fs.openSync(&quot;hello.txt&quot;, &quot;w&quot;);</span><br><span class="line">//                     不存在会自动新建</span><br><span class="line"></span><br><span class="line">//3\. 写入内容</span><br><span class="line">fs.writeFileSync(hello,&apos;hello word!&apos;);</span><br><span class="line"></span><br><span class="line">//4\. 保存并退出</span><br><span class="line">fs.closeSync(hello);</span><br></pre></td></tr></table></figure>
<p> <a href="https://github.com/AnsonZnl/StudyNodeJS/blob/master/%E8%AF%BE%E7%A8%8B%E7%AC%94%E8%AE%B0/%E8%AF%BE%E6%97%B630-%E8%AF%BE%E6%97%B634%E7%AC%94%E8%AE%B0.md#%E8%AF%BE%E6%97%B631" target="_blank" rel="noopener"></a></p>
<h3 id="文件操作："><a href="#文件操作：" class="headerlink" title="文件操作："></a>文件操作：</h3><ol>
<li>打开文件：<br><code>fs.open(path,flags[,mode],callback)</code><br>异步打开 异步都是回调 回调嵌套回调<br><code>fs.openSync(path,flags[,mode])</code><br>同步打开 </li>
</ol>
<p>文件标记（flags）： <a href="http://nodejs.cn/api/fs.html#fs_fs_open_path_flags_mode_callback" target="_blank" rel="noopener">http://nodejs.cn/api/fs.html#fs_fs_open_path_flags_mode_callback</a></p>
<p>一、同步打开文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">//1\. 引入模块 </span><br><span class="line">let fs = require(&apos;fs&apos;);</span><br><span class="line"></span><br><span class="line">//2.打开文件 同步</span><br><span class="line">var fd=fs.openSync(&apos;1.txt&apos;, &apos;w&apos;);</span><br><span class="line"></span><br><span class="line">//3.写入内容</span><br><span class="line">fs.writeFileSync(fd,&quot;hello world!&quot;); </span><br><span class="line"></span><br><span class="line">//4\. 保存并关闭</span><br><span class="line">fs.closeSync(fd);</span><br></pre></td></tr></table></figure></p>
<p> 二、异步打开文件<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">//1.引入模块</span><br><span class="line">let fs = require(&apos;fs&apos;);</span><br><span class="line"></span><br><span class="line">//2\. 打开文件</span><br><span class="line">fs.open(&apos;1.txt&apos;, &apos;a&apos;, (err, fd)=&gt;&#123;</span><br><span class="line">    //2.1判断是否出错</span><br><span class="line">    if(!err)&#123;</span><br><span class="line">        //正确 2.2写入文件</span><br><span class="line">        fs.writeFile(fd, &quot;今天天.....气真好！&quot;, (err)=&gt;&#123;</span><br><span class="line">             //2.2.1 写入成功</span><br><span class="line">             if(!err)&#123;</span><br><span class="line">                 console.log(&apos;写入成功&apos;);</span><br><span class="line">             &#125;else&#123;</span><br><span class="line">                 throw err;</span><br><span class="line">             &#125;</span><br><span class="line">             //2.3 关闭文件</span><br><span class="line">             fs.close(fd, (err)=&gt;&#123;</span><br><span class="line">                 if(!err)&#123;</span><br><span class="line">                     console.log(&apos;文件以保存并关闭&apos;)</span><br><span class="line">                 &#125;else&#123;</span><br><span class="line">                     throw err;</span><br><span class="line">                 &#125;</span><br><span class="line">             &#125;)</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        throw err;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure></p>
<p><a href="https://github.com/AnsonZnl/StudyNodeJS/blob/master/%E8%AF%BE%E7%A8%8B%E7%AC%94%E8%AE%B0/%E8%AF%BE%E6%97%B630-%E8%AF%BE%E6%97%B634%E7%AC%94%E8%AE%B0.md#%E8%AF%BE%E6%97%B632" target="_blank" rel="noopener"></a></p>
<h3 id="使用文件流写入"><a href="#使用文件流写入" class="headerlink" title="使用文件流写入"></a>使用文件流写入</h3><p>文件流写入： <a href="http://nodejs.cn/api/fs.html#fs_fs_createwritestream_path_options" target="_blank" rel="noopener">http://nodejs.cn/api/fs.html#fs_fs_createwritestream_path_options</a></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">//同步操作</span><br><span class="line"></span><br><span class="line">//1\. 引入模块</span><br><span class="line">let fs= require(&apos;fs&apos;);</span><br><span class="line"></span><br><span class="line">//2.建立通道</span><br><span class="line">let ws = fs.createWriteStream(&apos;fsw.txt&apos;)</span><br><span class="line"></span><br><span class="line">//3.打开通道</span><br><span class="line">ws.once(&apos;open&apos;, ()=&gt;&#123;</span><br><span class="line">    console.log(&apos;通道已经打开&apos;);</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line">ws.once(&apos;close&apos;, ()=&gt;&#123;</span><br><span class="line">    console.log(&apos;通道已经关闭&apos;);</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line">//4\. 写入内容</span><br><span class="line">ws.write(&apos;我爱你，&apos;);</span><br><span class="line">ws.write(&apos;我爱你，&apos;);</span><br><span class="line">ws.write(&apos;我爱你，&apos;);</span><br></pre></td></tr></table></figure>
<p> <a href="https://github.com/AnsonZnl/StudyNodeJS/blob/master/%E8%AF%BE%E7%A8%8B%E7%AC%94%E8%AE%B0/%E8%AF%BE%E6%97%B630-%E8%AF%BE%E6%97%B634%E7%AC%94%E8%AE%B0.md#%E8%AF%BE%E6%97%B633" target="_blank" rel="noopener"></a></p>
<h3 id="读写文件："><a href="#读写文件：" class="headerlink" title="读写文件："></a>读写文件：</h3><p>文档地址：<a href="http://nodejs.cn/api/fs.html#fs_fs_readfile_path_options_callback" target="_blank" rel="noopener">http://nodejs.cn/api/fs.html#fs_fs_readfile_path_options_callback</a><br>读取文档：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line">//1\. 引入模块</span><br><span class="line">let fs = require(&apos;fs&apos;);</span><br><span class="line"></span><br><span class="line">//2\. 读取文件</span><br><span class="line">fs.readFile(&apos;source/hello.txt&apos;,&apos;utf8&apos;,(err,data)=&gt;&#123;</span><br><span class="line">    //判断是否成功</span><br><span class="line">    if(!err)&#123;</span><br><span class="line">        console.log(data);//</span><br><span class="line">        // console.log(data.toString());</span><br><span class="line">        //data 默认读取的是二进制 使用toString() 方法转换成</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        throw err;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line">读取图片：</span><br><span class="line"></span><br><span class="line">//3\. 读取图片</span><br><span class="line">fs.readFile(&quot;source/psb.jpg&quot;,(err,data)=&gt;&#123;</span><br><span class="line">    //判断是否成功</span><br><span class="line">    if(!err)&#123;</span><br><span class="line">        //写入图片</span><br><span class="line">        fs.writeFile(&apos;img.jpg&apos;, data, (err)=&gt;&#123;</span><br><span class="line">            if(!err)&#123;</span><br><span class="line">                console.log(&apos;写入成功！&apos;)</span><br><span class="line">            &#125;else&#123;</span><br><span class="line">                throw err;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        throw err;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure>
<p><a href="https://github.com/AnsonZnl/StudyNodeJS/blob/master/%E8%AF%BE%E7%A8%8B%E7%AC%94%E8%AE%B0/%E8%AF%BE%E6%97%B630-%E8%AF%BE%E6%97%B634%E7%AC%94%E8%AE%B0.md#%E8%AF%BE%E6%97%B634" target="_blank" rel="noopener"></a></p>
<p><strong>读取视频:</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">//1\. 引入模块</span><br><span class="line">let fs= require(&apos;fs&apos;);</span><br><span class="line"></span><br><span class="line">//2\. 读取视频</span><br><span class="line">fs.readFile(&apos;source/cddbb.mp4&apos;, (err, data)=&gt;&#123;</span><br><span class="line">    if(!err)&#123;</span><br><span class="line">        // 写入视频</span><br><span class="line">        fs.writeFile(&apos;nmx.mp4&apos;, data, (err)=&gt;&#123;</span><br><span class="line">            if(!err)&#123;</span><br><span class="line">                console.log(&apos;写入成功！&apos;);</span><br><span class="line">            &#125;else&#123;</span><br><span class="line">                throw err;</span><br><span class="line">            &#125;</span><br><span class="line">        &#125;)</span><br><span class="line">    &#125;else&#123;</span><br><span class="line">        throw err;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line">//3\. 流式文件的读入（批量文件处理）</span><br><span class="line">let re= fs.createReadStream(&apos;source/cddbb.mp4&apos;);</span><br><span class="line">//建立读取流</span><br><span class="line">let ws= fs.createWriteStream(&apos;新建的视频.mp4&apos;);</span><br><span class="line">//建立写入流</span><br><span class="line"></span><br><span class="line">//4\. 创建管道</span><br><span class="line">re.pipe(ws);//文件流传输</span><br><span class="line">console.log(&apos;文件流传输完成&apos;)</span><br></pre></td></tr></table></figure>
<p>参考：<a href="https://www.jb51.net/article/133553.htm" target="_blank" rel="noopener">详解NodeJS文件系统fs</a><br>我的GitHub总结的<a href="https://github.com/AnsonZnl/StudyNodeJS" target="_blank" rel="noopener">NodeJS笔记</a></p>

        </div>

        <blockquote class="post-copyright">
    
    <footer>
        <a href="http://yoursite.com">
            <img src="https://yscoder.github.io/img/face.jpg" alt="张宁乐">
            张宁乐
        </a>
    </footer>
</blockquote>

        


        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/NodeJS/">NodeJS</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&title=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&pic=https://yscoder.github.io/img/face.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&title=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&source=张宁乐,博客" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2018/11/15/初试MongoDB数据库/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">初试MongoDB数据库</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2018/11/05/Node中的Buffer/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">NodeJS中的Buffer</h4>
      </a>
    </div>
  
</nav>



    











    <!-- Valine Comments -->
    <div class="comments vcomment" id="comments"></div>
    <script src="//cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
    <script src="//unpkg.com/valine@latest/dist/Valine.min.js"></script>
    <!-- Valine Comments script -->
    <script>
        var GUEST_INFO = ['nick','mail','link'];
        var guest_info = 'nick,mail'.split(',').filter(function(item){
          return GUEST_INFO.indexOf(item) > -1
        });
        new Valine({
            el: '#comments',
            notify: 'false' == 'true',
            verify: 'false' == 'true',
            appId: "gbSwUaucLkuxqOLxm131Mg9U-gzGzoHsz",
            appKey: "b9xU2qIPrm06S0uymbAfrGMD",
            avatar: "mm",
            placeholder: "要不要说点什么？",
            guest_info: guest_info.length == 0 ? GUEST_INFO : guest_info,
            pageSize: "10"
        })
    </script>
    <!-- Valine Comments end -->







</article>



</div>

        <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        站点总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        站点总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循 <a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p><span>张宁乐 &copy; 2017 - 2019</span>
            <span>
                
                Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a>
            </span>
			<span>
					Hosted by <a href="https://pages.coding.me" style="font-weight: bold">Coding Pages</a>
			  </span>
        </p>
    </div>
</footer>
<!-- <script>
(function(){
    var bp = document.createElement("script");
    var curProtocol = window.location.protocol.split(":")[0];
    if (curProtocol === "https") {
        bp.src = "https://zz.bdstatic.com/linksubmit/push.js";
    }
    else {
        bp.src = "http://push.zhanzhang.baidu.com/push.js";
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script> -->

    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&title=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&pic=https://yscoder.github.io/img/face.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&title=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&source=张宁乐,博客" data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《NodeJS文件系统（fs）与流（stream）》 — Anson's Blog&url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/&via=http://yoursite.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://yoursite.com/2018/11/08/NodeJs文件系统（fs）与流（stream）/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: false };


</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>





</body>
</html>
